package com.example.lenovo.demo.view;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lenovo.demo.R;
import com.example.lenovo.demo.presenter.CityFirstHotFgPresenter;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;


/**
 * Created by Lenovo on 2017/1/15.
 */
@ContentView(R.layout.fragment_cityfirsthot)
public class CityFirstHotFragment extends Fragment {
    private View view;
    @ViewInject(R.id.cityfirsthot_fg_rv)
    private RecyclerView recyclerView;
    private String id;
    private CityFirstHotFgPresenter presenter;
    private ProgressDialog progressDialog;

    public static CityFirstHotFragment getFragment(String id){
        Bundle bundle=new Bundle();
        CityFirstHotFragment fragment=new CityFirstHotFragment();
        bundle.putString("msg",id);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view= x.view().inject(this,inflater,container);
        init();
        return view;
    }

    private void init() {
        id=getArguments().getString("msg");
        progressDialog=new ProgressDialog(getActivity());
        progressDialog.setTitle("提示");
        progressDialog.setMessage("正在加载...");
        progressDialog.setCancelable(true);
        presenter=new CityFirstHotFgPresenter();
        presenter.sendView(recyclerView,getActivity(),id,progressDialog);
        presenter.initData();
    }
}
